package mr.fileToFile;

import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
/**
 * 
 * @author 李岩飞
 * @email eliyanfei@126.com	
 * 2017年12月18日 上午10:16:54
 *
 */
public class S1MMEReducer extends Reducer<Text, Text, Text, Text> {

	@Override
	protected void cleanup(Context context) throws IOException, InterruptedException {
		super.cleanup(context);
	}

	Text txt = new Text();

	@Override
	protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
		try {
			StringBuffer sb = new StringBuffer();
			int i = 0;
			for (Text value : values) {
				if (i++ > 50)
					break;
				sb.append(value.toString()).append("_");
			}
			txt.set(sb.toString());
			context.write(key, txt);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}